<template>
  <div>
    <!-- v-bind指令：给标签设置属性 -->
    <!-- 语法：v-bind:属性名="属性值"  -->
    <!-- 简写: :属性名="属性值 -->
    <!-- <a v-bind:href="url">百度</a>
    <img :src="imgUrl" alt=""> -->

    {{ money }}
    <div>

      <!--绑定事件: v-on:事件名="事件处理函数" -->
      <!-- 简写: @事件名="事件处理函数" -->
      <button @click="addMoney(10 - (money % 10))">取整</button>
      <button @click="addMoney(20)">+20</button>
      <button @click="money++">+1</button>
      <button @click="addTwoMoney">+10</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      url: "https:www.baidu.com",
      imgUrl:
        "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Faaaju.oicp.net%3A93%2Fpicture%2Fbiaoqing%2Fpic%2Fa%2F34%2F26107.jpeg&refer=http%3A%2F%2Faaaju.oicp.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1667548326&t=0d4715567fb7bdc88b476a047b9ea352",
      money: 100,
    };
  },
  methods: {
    addMoney(sum) {
      this.money += sum;
    },
    addTwoMoney() {
      if (this.money >= 200) return;

      this.money += 10;
    },
  },
};
</script>

<style>
</style>